/*************************************************************
 * File: SerialNumberGeneratorUsingUUID.java
 * Copyright (c) 2012
 * Author: Shaobin.Software@gmail.com Shaobin_Software@163.com 
 * Date: Jan 21, 2013
 * Description: 
 ************************************************************/
package snow.core.toolkit.generator;

import java.security.SecureRandom;

import org.apache.commons.lang.StringUtils;

/**
 *
 */
public class SerialNumberGeneratorUsingUUID implements SerialNumberGenerator {

	private final SecureRandom secureRandom;
	
	private String prefix;
	private final Object mutex = new Object();

	public SerialNumberGeneratorUsingUUID() {
		secureRandom = new SecureRandom();
	}

	/**
	 * @return
	 * @see snow.core.toolkit.generator.SerialNumberGenerator#generateSerialNumber()
	 */
	public String generateSerialNumber() {
		return null;
	}

	public SecureRandom getSecureRandom() {
		return secureRandom;
	}

	public String getPrefix() {
		if (StringUtils.isBlank(prefix)) {
			synchronized (mutex) {
				if (StringUtils.isBlank(prefix)) {
					StringBuilder builder = new StringBuilder();
					
					prefix = builder.toString();
				}
			}
		}
		return prefix;
	}

}
